call to PostgreSQL function executed twice ?
am 30.11.2006 16:05:30 von Jan van der WeijdeThis is a multi-part message in MIME format.
style=3D"FONT-SIZE: 11pt; COLOR: windowtext; FONT-FAMILY: Verdana; =
style=3D"FONT-SIZE: 10pt; COLOR: #999999; FONT-FAMILY: Verdana; =
style=3D"COLOR: windowtext">
------_=_NextPart_001_01C71490.FA1C03F8
Content-Type: multipart/alternative;
boundary="----_=_NextPart_002_01C71490.FA1C03F8"
------_=_NextPart_002_01C71490.FA1C03F8
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Hello,
=20
I have an ODBC C-program that executes a call to a PostgreSQL function
called testprocedure.
The call is first prepared, using SQLPrepare(). Next SQLNumResultCols()
and SQLDescribeCol() are used to get information about the result of the
call.
Finally SQLExecute() is called to execute the call to the procedure.
The result now is that two records are inserted into table test, with
other words the PostgreSQL function testprocedure is called twice!
=20
I use the next procedure:
=20
CREATE OR REPLACE FUNCTION testprocedure("varchar") RETURNS void AS $$
BEGIN=20
insert into test values($1);
end;=20
$$
language 'plpgsql';
=20
And the prepared and executed call is "select testProcedure('vib') as
strout"
=20
I use PostgreSQL 8.1.4 on Windows XP professional and ODBC Driver
'PostgreSQL ANSI', version 8.01.02.00 from the PostgreSQL Global
Deveopment Group
=20
It turns out, that SQLNumResultCols() or SQLDescribeCol() also execute
the call. And that the call to SQLExecute() then executes it a second
time.=20
When I leave SQLNumResultCols() out, SQLDescribeCol() will execute the
statement and the other way around.
=20
Is this a bug or do I do something wrong?
From what I understand from the ODBC documentation, only SQLExecute()
should execute a prepared function call.
=20
Thank you,
Jan
=20
Jan Ch. van der Weijde
Senior Software Engineer
Schipholweg 103
2316 XC Leiden
The Netherlands
+31 71 368 1173 phone
+31 71 368 1181 fax
Jan.van.der.Weijde@attachmate.com
www.attachmate.com
=20
=20
------_=_NextPart_002_01C71490.FA1C03F8
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
charset=3Dus-ascii">
an ODBC=20
C-program that executes a call to a PostgreSQL function
face=3D"Times New Roman" size=3D3>called =
testprocedure.
SQLPrepare().=20
Next SQLNumResultCols() and SQLDescribeCol() are used to get information =
about=20
the result of the call.
called to=20
execute the call to the procedure.
result now is=20
that two records are inserted into table test, with other words the =
PostgreSQL=20
function testprocedure is called =
twice!
the next=20
procedure:
testprocedure("varchar") RETURNS void AS $$
BEGIN
insert into =
test=20
values($1);
end;
$$
language 'plpgsql';
the prepared and=20
executed call is "select testProcedure('vib') as =
strout"
and ODBC=20
Driver 'PostgreSQL ANSI', version 8.01.02.00 from the PostgreSQL Global=20
Deveopment Group
turns out, that=20
SQLNumResultCols() or =
SQLDescribeCol() also=20
execute the call. And that the call to SQLExecute() then =
executes it a=20
second time.
leave
face=3D"Times New Roman" size=3D3>SQLNumResultCols() =
out,
face=3D"Times New Roman" size=3D3>SQLDescribeCol() will execute the =
statement and=20
the other way around.
this a bug or do=20
I do something wrong?
what I=20
understand from the ODBC documentation, only SQLExecute() should execute =
a=20
prepared function call.
you,
mso-ansi-language: NL">Jan=20
Ch. van der Weijde
style=3D"FONT-SIZE: 9pt; COLOR: #003399; FONT-FAMILY: Verdana; =
mso-ansi-language: NL">Senior=20
Software Engineer
style=3D"mso-ansi-language: NL">
"urn:schemas-microsoft-com:office:office" />
mso-bidi-font-size: 10.0pt">
href=3D"http://www.attachmate.com/">
class=3DMsoHyperlink>
lang=3DNL=20
style=3D"FONT-SIZE: 11pt; FONT-FAMILY: Verdana; TEXT-DECORATION: none; =
mso-ansi-language: NL; mso-bidi-font-size: 10.0pt; text-underline: =
none">
mso-bidi-font-size: 12.0pt">Schipholweg=20
103
2316 XC Leiden
The Netherlands
+31 71 368 1173 =
phone
+31=20
71 368 1181 fax
Jan.van.der.Weijde@attachmate.com
style=3D"FONT-SIZE: 9pt; COLOR: #003399; FONT-FAMILY: Verdana">
href=3D"outbind://348/www.attachmate.com">www.attachmate.com
------_=_NextPart_002_01C71490.FA1C03F8--
------_=_NextPart_001_01C71490.FA1C03F8
Content-Type: image/gif;
name="atte12f6.gif"
Content-Transfer-Encoding: base64
Content-ID: <147303214@30112006-3526>
Content-Description: atte12f6.gif
Content-Location: atte12f6.gif
R0lGODlhlAAVANUAAAAnk5aq1djY2Fl4uwMxmFBQUEdotMjU6eXl5TRarJeX l7a2tmuGwjQ0Ndnh
8HmSyNLb7QAZjHd3d7TD4YmJiqK02fz9/vH0+qOjo8fHyOPp9BtDoYGZzGNj YxISEr3K5e3x+HGM
xiMjIyNKpMHN5qy83vj6/A87neru9ZCl0ixTqfX4+158vfr8/ff4+PLy8qe4 27jG4zxfr52v12aC
wN/m8rC/305vt0BerwAhkIqg0EFjsWJ/vy1MpgAAAP///yH5BAAAAAAALAAA AACUABUAAAb/wJ9Q
KFgoJJ1OIdmRYDKIoXRKrVqv2Kx2y+12Mx2Rb0wu+zwNCsrLbmMhE5LJTa9L MR6z3twQtFswDzMr
UgcPHA52VSw5GxqKbCApDxNuGXlkHkiYHgUNY0o+BXNeKzsRPWtDKRE5NpBT AxEnj7BcDicRLG0u
BWUiCxgKCwUFEgUUBR4KCmMLbCsGEQkXUjM5BDG2Q4yO21sOGxEMbQKYPg0I GGMKAgK+HhgSIpgd
VgeTIRwVNULROSMmHCBB4kAIAAR0DCRB6IcFEilC6KtQa8iFCRxCCEokpNsK FDMehAjAEQVBEyAq
aKwAQsgBHQw42GghxcQEHRI5lGj5I1yO/xsDP/T7sQLjxFogISwgIwJBhjMS kil4IcEHsA5kGriY
UuMGgQhgW53QYaGFAYQE0qpdC+BEIgcGvoZtFGDIBBUA5p54UG0AwBTiWgHY UAlGWw4JwOYAkMCQ
3MU3apFIkDcsgBGvwqElAIDDjxiU525IYQHCgAoUyCj40aABBgr1UCwQ0WHB pzN+hoBIsFjFgAEG
TgAA8Ors2uNqN9RAoSICAN/AhWf7AYPzZQMyOOdgYYIFQoQJDIzgPAJEie/P gw8/gU3GjhMEcoT4
AWFD+984OJ+oUWPDZgApkMAeATuwcIN9AOjQwgEoVI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